import baidu_translate as fanyi
import os
os.environ['HTTPS_PROXY'] = 'https://127.0.0.1:7890'
os.environ['HTTP_PROXY'] = 'http://127.0.0.1:7890'
# 明确指定源语言和目标语言
result = fanyi.translate_text('Hello, World!', from_=fanyi.Lang.EN, to=fanyi.Lang.ZH)
result_ru = fanyi.translate_text('Hello, World!', from_=fanyi.Lang.EN, to=fanyi.Lang.RU)
print(result, result_ru)
# 你好，世界！ Здравствуйте, Мир!

# 对于中文文本，明确指定源语言
result = fanyi.translate_text('我们是中国人，我们爱自己的祖国！', from_=fanyi.Lang.ZH, to=fanyi.Lang.EN)
print(result)
# We are Chinese, we love our motherland!

# 金融术语翻译
result_common = fanyi.translate_text('年化收益率', from_=fanyi.Lang.ZH, to=fanyi.Lang.EN)
result_domain = fanyi.translate_text('年化收益率', from_=fanyi.Lang.ZH, to=fanyi.Lang.EN, domain=fanyi.Domain.FINANCE)
print(result_common, '&', result_domain)
# Annualized rate of return & Annualized yield


